package JavaSE.d6;

public class Test2 {
    public static void main(String[] args) throws InterruptedException {
        B b = new B();
        B b2 = new B();
        B b3 = new B();
        Thread thread = new Thread(b2);//创建线程对象，参数实现runnable接口的类
        thread.setName("b2");//线程名名称
        thread.start();//启动线程
        while (true){
            System.out.println("我是主线程，正在执行");
            Thread.sleep(50);
        }
    }
}
class B implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("我来自是类B的线程"+Thread.currentThread().getName()+"，正在执行");
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}